package cn.blossoming.dao.domain;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;

@Entity
@DynamicInsert
@DynamicUpdate
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "video")
public class VideoEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    private String picture;
    private String title;
    private String url;
    private String sourceUrl;
    private LocalTime time;
    private Integer readNum;
    private Integer commentNum;
    private Integer praiseNum;
    private String remark;
    private LocalDateTime updateTime;
    private LocalDateTime createTime;

    @ManyToOne
    @JoinColumn(name = "user_id")
    private UserEntity user;

    @OneToMany(mappedBy = "video")
    private List<VideoCommentEntity> videoComments;

    @OneToMany(mappedBy = "video")
    private List<VideoPraiseEntity> videoPraises;

    @OneToMany(mappedBy = "video")

    private List<VideoReadEntity> videoReads;

    @OneToMany(mappedBy = "video")
    private List<VideoTagEntity> videoTags;
}
